var common = require("../../../utils/common.js");
var app = getApp();
Page({
    data: {
        status: true,
        hidden: false,
        searchText: "",
        foodList: []
    },
    onLoad: function(){
        var that = this;
        app.getSystemInfo(function(systemInfo){
            //更新数据
            that.setData({
                systemInfo:systemInfo
            })
        })

        this.setData({hidden:true});
        
    },
    listenSearchText: function(e){
        var searchText = e.detail.value;
        this.setData({searchText:searchText});
    },
    searchFood: function(){
        var that = this;
        that.setData({"hidden": false});
        common.reqService("/Food/getNewFoodList", {"key": that.data.searchText}, that.data.systemInfo, false, function(res){
            that.setData({"hidden": true});
            if(res.data.length > 0){
                that.setData({foodList: res.data});
            }else{
                that.setData({foodList: []});
                common.toast(that, "没有找到此记录");
            }
        })
    },
    foodItem: function(event){
        var foodCode = event.currentTarget.dataset.foodCode;
        wx.navigateTo({
            url: '../detail/index?code='+foodCode
        })
    },
    hiddenToast: function(){
      this.setData({status: true, msg:''});
    }
})